/* 
 * File:        mathematicalFunctions.h
 * Author:      Cody TV Weber
 * Date:        March 27, 2014, 12:18 AM
 * Description: Some useful common mathematical functions
 */

#ifndef MATHEMATICALFUNCTIONS_H
#define	MATHEMATICALFUNCTIONS_H

/*
 * TYPE absoluteValue(TYPE c) - Returns the absolute value.  *GIGO*
 */
template<typename TYPE>
inline
TYPE absoluteValue(TYPE number) {
    if (number < 0) {
        TYPE newNumber = (number * -1);
        return newNumber;
    }
    return number;
}

/*
 * double iterativeProduct(TYPE matrix[], int numberOfElements) - 
 *          Returns the iterative product of the elements within the
 *          elements in the array.  (Expected output: a double value).*GIGO*
 */
template<typename TYPE>
inline
double iterativeProduct(array<TYPE>^ matrix, int numberOfElements) {
    double result = 1;
    
    // Multiplies each number in the array.
    for(int i=0; i<numberOfElements; i++){
        result *= matrix[i];
    }
    
    return result;  // Returns the product.
}


#endif	/* MATHEMATICALFUNCTIONS_H */

